package com.swt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.swt.service.TbUserAddrService;
import com.swt.domain.TbUserAddr;
import com.swt.mapper.TbUserAddrMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 苏
* @description 针对表【yesapi_xbinstore_tb_user_addr(B2C商城-用户地址)】的数据库操作Service实现
* @createDate 2022-05-16 09:40:37
*/
@Service
public class TbUserAddrServiceImpl implements TbUserAddrService {
    @Autowired
    private TbUserAddrMapper addrMapper;
    @Override
    public List<TbUserAddr> selectAllUserAddr() {
        return addrMapper.selectList(null);
    }

    @Override
    public int delectUserAddr(String id) {
        return addrMapper.deleteById(id);
    }

    @Override
    public int updateUserAddr(TbUserAddr UserAddr) {
        return addrMapper.updateById(UserAddr);
    }

    @Override
    public int inserUserAddr(String userId,TbUserAddr UserAddr) {
        UserAddr.setUserId(userId);
        return addrMapper.insert(UserAddr);
    }

    @Override
    public List<TbUserAddr> selectbyUserAddrdid(String id) {
        LambdaQueryWrapper<TbUserAddr> lqw = new LambdaQueryWrapper<>();
        lqw.eq(TbUserAddr::getUserId,id);
        return addrMapper.selectList(lqw);
    }

    @Override
    public Page<TbUserAddr> pageUserAddr(Integer page, Integer start) {
        Page<TbUserAddr> userPge = new Page<>(page,start);
        return addrMapper.selectPage(userPge,null);
    }


}




